package pzl.com.bluetooth.task;

import android.bluetooth.BluetoothSocket;
import android.util.Log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 服务端数据接收线程
 *
 * @author zl.peng
 * @version [1.0, 2016-10-13]
 */
@Deprecated
public class ServiceReceiveThread extends Thread {
    static final String TAG = "ServiceReceiveThread";
    BluetoothSocket mSocket;

    public ServiceReceiveThread(BluetoothSocket socket) {
        mSocket = socket;
    }

    @Override
    public void run() {
        super.run();

        BufferedReader bufferedReader = null;
        String receivedMsg = null;

        try {
            bufferedReader = new BufferedReader(new InputStreamReader(mSocket.getInputStream()));
            while ((receivedMsg = bufferedReader.readLine()) != null) {
                Log.d(TAG, "接收到远程数据：" + receivedMsg);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
